Skip to content

gh-162350: Add AC vectorcall for memoryview - #162471

Open
tanloong wants to merge 1 commit into
python:mainfrom
tanloong:separate_memoryview_vectorcall
Open

tanloong wants to merge 1 commit into
python:mainfrom
tanloong:separate_memoryview_vectorcall

Conversation

@tanloong

@tanloong tanloong commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Add @vectorcall to memoryview.__new__. There is no change of exception text for bad arguments.

Benchmark:

+--------------------------------+--------+------------------------+
| Benchmark                      | main   | patch                  |
+================================+========+========================+
| memoryview(b)                  | 170 ns | 143 ns: 1.19x faster   |
| builtins.memoryview(b)         | 179 ns | 149 ns: 1.20x faster   |
+--------------------------------+--------+------------------------+
| Geometric mean                 | (ref)  | 1.20x faster           |
+--------------------------------+--------+------------------------+
Details
import pyperf

SETUP = """
import builtins
b = b'abc'
memoryview = builtins.memoryview
"""

CASES = [
    ('memoryview(b)', 'memoryview(b)'),
    ('builtins.memoryview(b)', 'builtins.memoryview(b)')
]

runner = pyperf.Runner()
for name, stmt in CASES:
    runner.timeit(name, stmt=stmt, setup=SETUP)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants